package com.balakitbbs.controller;

import org.springframework.beans.factory.annotation.Autowired; 
import java.util.*;               
import org.springframework.stereotype.Controller;               
import org.springframework.web.bind.annotation.PathVariable;               
import org.springframework.web.bind.annotation.RequestMapping;               
import org.springframework.web.servlet.ModelAndView;               
import com.balakitbbs.page.Page;               
import com.balakitbbs.page.SearchPageUtil;               
import com.balakitbbs.service.Bala_personService;
import com.balakitbbs.entity.Bala_person;
   /**
    * bala_person Controller类
    */ 
@Controller
public class Bala_personController{
	@Autowired
	private Bala_personService bala_personservice;

//增加人员表
@RequestMapping("/page/{pageIndex}/{pageSize}/addBala_person")
public String addBala_person(Bala_person bala_person,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_person.setCdate(new Date());
	bala_person.setId(UUID.randomUUID().toString());
	bala_personservice.addBala_person(bala_person);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_person.do";
}


//删除人员表
@RequestMapping("/page/{Id}/{pageIndex}/{pageSize}/delBala_person")
public String delBala_person(@PathVariable String Id,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_personservice.delBala_person(Id);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_person.do";
}


//修改人员表
@RequestMapping("/page/{pageIndex}/{pageSize}/updateBala_person")
public String updateBala_person(Bala_person bala_person,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	bala_person.setUdate(new Date());
	bala_personservice.updateBala_person(bala_person);
	return "redirect:/page/"+pageIndex+"/"+pageSize+"/selectBala_person.do";
}


//查询人员表
@RequestMapping("/page/{pageIndex}/{pageSize}/selectBala_person")
public ModelAndView selectBala_persons(Bala_person bala_person,@PathVariable Integer pageIndex,@PathVariable Integer pageSize){
	ModelAndView modelAndView = new ModelAndView();
	int selectBala_personCount = bala_personservice.selectBala_personsByPOJOCount(bala_person);
	Page page = new Page(pageIndex, pageSize, selectBala_personCount);
	SearchPageUtil spu = new SearchPageUtil();
	spu.setPage(page);
	modelAndView.addObject("data", bala_personservice.selectBala_personsByPojoPage(spu, bala_person));
	modelAndView.addObject("page", page);
	modelAndView.addObject("s", 1);
	modelAndView.addObject("po", new Bala_person());
	modelAndView.setViewName("/WEB-INF/page/bala_person.jsp");
	return modelAndView;
}

}

